//
//  RefundProofTableViewCell.m
//  jingdongfang
//
//  Created by MTiMac02 on 2018/1/17.
//  Copyright © 2018年 LJL. All rights reserved.
//

#import "SellerRefundTableViewCell.h"
@interface SellerRefundTableViewCell ()
{
    UILabel *agreeRefundTime;
    UILabel *rejectOrAgree;
    UILabel *rejectRefund;
    UILabel *rejectRefundDetail;
}
@end
@implementation SellerRefundTableViewCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.contentView.backgroundColor = [UIColor c3Color];
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self createUI];
    }
    return self;
}
- (void)createUI {
    self.contentView.backgroundColor = [UIColor c3Color];
    //同意退款时间;
    agreeRefundTime = [[UILabel alloc] initWithFrame:CGRectZero];
    agreeRefundTime.font = [UIFont font13];
    agreeRefundTime.textColor = [UIColor c5Color];
    [agreeRefundTime sizeToFit];
    [self.contentView addSubview:agreeRefundTime];
    //卖家是否同意退款
    rejectOrAgree=[[UILabel alloc]initWithFrame:CGRectZero];
    rejectOrAgree.font=[UIFont font13];
    rejectOrAgree.textColor=[UIColor appColor];
    [rejectOrAgree sizeToFit];
    [self.contentView addSubview:rejectOrAgree];
    //拒绝退款
    rejectRefund=[[UILabel alloc]initWithFrame:CGRectZero];
    rejectRefund.font=[UIFont font13];
    rejectRefund.textColor=[UIColor c5Color];
    [self.contentView addSubview:rejectRefund];
    rejectRefundDetail=[[UILabel alloc]initWithFrame:CGRectZero];
    rejectRefundDetail.font=[UIFont font13];
    rejectRefundDetail.textColor=[UIColor c5Color];
    [self.contentView addSubview:rejectRefundDetail];
}
-(void)layoutSubviews{
    [super layoutSubviews];
    //同意退款时间;
//    agreeRefundTime.text = [@"" stringByAppendingString:[NSDate timestampToString:self.sellerRefundInfo.refundTime Format:@"yyyy-MM-dd HH:mm:ss"]];
    agreeRefundTime.text=self.sellerRefundInfo.refundTime;
    [agreeRefundTime sizeToFit];

    //卖家是否同意退款
    if ([self.sellerRefundInfo.refundState integerValue]==1) {
        rejectOrAgree.text=NSLocalizedString(@"Refund Approved by Seller", nil);
    }
    if([self.sellerRefundInfo.refundState integerValue]==2){
        rejectOrAgree.text=NSLocalizedString(@"Refund Refused by Seller", nil);
    }
    [rejectOrAgree sizeToFit];
    //拒绝退款
    rejectRefund.text=NSLocalizedString(@"Refused Reason(s):", nil);
    [rejectRefund sizeToFit];
    [rejectRefundDetail setContentMode:UIViewContentModeTop];
    rejectRefundDetail.text=self.sellerRefundInfo.refundReason.length>0?self.sellerRefundInfo.refundReason:@"";
    [rejectRefundDetail sizeToFit];
    rejectRefundDetail.width=KSCREENWIDTH-rejectRefund.width-50;
    rejectRefundDetail.height=35;
    [rejectRefundDetail setLineBreakMode:NSLineBreakByClipping];
    [rejectRefundDetail setNumberOfLines:0];
    rejectRefundDetail.text = [self.sellerRefundInfo.refundReason stringByAppendingString:@"\n "];
    if([self.sellerRefundInfo.refundState integerValue]==1){
        rejectRefund.hidden=YES;
        rejectRefundDetail.hidden=YES;
    }
    agreeRefundTime.x=15;
    agreeRefundTime.y=5;
    rejectOrAgree.x=agreeRefundTime.x;
    rejectOrAgree.y=agreeRefundTime.bottom+3;
    rejectRefund.x=rejectOrAgree.x;
    rejectRefund.y=rejectOrAgree.bottom+3;
    rejectRefundDetail.x=rejectRefund.right+3;
    rejectRefundDetail.y=rejectRefund.y-2;
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
